///
/// @ProjectName:    learning_rust
/// @Description:    
/// @File:           jz11.rs
/// @Author:         wujehy
/// @Email:          wujehy@qq.com
/// @Time:           2021-07-01 22:05
///

struct Solution{

}

impl Solution {
    fn new() -> Self {
        Solution{}
    }

    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * @param n int整型
     * @return int整型
     */
    #[allow(non_snake_case)]
    pub fn NumberOf1(&self, n: i32) -> i32 {
        // write code here
        let mut count = 0 ;
        let mut n = n;
        while n != 0 {
            n &= n - 1 ;
            count +=1;
        }
        count
    }
}
#[test]
fn test7(){
    let s = Solution::new();
    let expext = 2;
    assert_eq!(expext , s.NumberOf1(3));

}